/* ---------------------------------------------------------------------- */
/* Script generated with: DeZign for Databases v4.1.3                     */
/* Target DBMS:           MS SQL Server 2005                              */
/* Project file:          Project1.dez                                    */
/* Project name:                                                          */
/* Author:                                                                */
/* Script type:           Database creation script                        */
/* Created on:            2012-05-07 15:03                                */
/* ---------------------------------------------------------------------- */


/* ---------------------------------------------------------------------- */
/* Tables                                                                 */
/* ---------------------------------------------------------------------- */

/* ---------------------------------------------------------------------- */
/* Add table "sys_Function"                                               */
/* ---------------------------------------------------------------------- */

CREATE TABLE [sys_Function] (
    [id] INTEGER IDENTITY(0,1) NOT NULL,
    [name] NVARCHAR(40),
    [image] NVARCHAR(100),
    [link] NVARCHAR(100),
    [ParentID] INTEGER,
    [last_update] DATETIME,
    CONSTRAINT [PK_sys_Function] PRIMARY KEY ([id])
)
GO

/* ---------------------------------------------------------------------- */
/* Add table "sys_Role_Function"                                          */
/* ---------------------------------------------------------------------- */

CREATE TABLE [sys_Role_Function] (
    [id] INTEGER IDENTITY(0,1) NOT NULL,
    [RoleID] INTEGER,
    [FuctionID] INTEGER,
    [last_update] DATETIME,
    CONSTRAINT [PK_sys_Role_Function] PRIMARY KEY ([id])
)
GO

/* ---------------------------------------------------------------------- */
/* Add table "VaiTro"                                                     */
/* ---------------------------------------------------------------------- */

CREATE TABLE [VaiTro] (
    [id] INTEGER IDENTITY(0,1) NOT NULL,
    [ten] NVARCHAR(40),
    [ghi_chu] NVARCHAR(100),
    [ngay_cap_nhat_cuoi] DATETIME,
    CONSTRAINT [PK_VaiTro] PRIMARY KEY ([id])
)
GO

/* ---------------------------------------------------------------------- */
/* Add table "ThanhVien"                                                  */
/* ---------------------------------------------------------------------- */

CREATE TABLE [ThanhVien] (
    [id] INTEGER IDENTITY(0,1) NOT NULL,
    [ten_dang_nhap] VARCHAR(40),
    [mat_khau] VARCHAR(40),
    [ma_vai_tro] INTEGER,
    [ngay_cap_nhat_cuoi] DATETIME,
    CONSTRAINT [PK_ThanhVien] PRIMARY KEY ([id])
)
GO

/* ---------------------------------------------------------------------- */
/* Add table "KhachHang"                                                  */
/* ---------------------------------------------------------------------- */

CREATE TABLE [KhachHang] (
    [id] INTEGER IDENTITY(0,1) NOT NULL,
    [ten] NVARCHAR(40),
    [dia_chi] NVARCHAR(100),
    [tel] INTEGER,
    [fax] INTEGER,
    [so_tai_khoan] INTEGER,
    [ngan_hang] NVARCHAR(40),
    [ma_so_thue] INTEGER,
    [ghi_chu] NVARCHAR(80),
    [ngay_cap_nhat_cuoi] DATETIME,
    CONSTRAINT [PK_KhachHang] PRIMARY KEY ([id])
)
GO

/* ---------------------------------------------------------------------- */
/* Add table "KhachHang_HangHoa"                                          */
/* ---------------------------------------------------------------------- */

CREATE TABLE [KhachHang_HangHoa] (
    [id] INTEGER IDENTITY(0,1) NOT NULL,
    [ma_hang_hoa] INTEGER,
    [ma_khach_hang] INTEGER,
    [gia_ban] FLOAT,
    CONSTRAINT [PK_KhachHang_HangHoa] PRIMARY KEY ([id])
)
GO

/* ---------------------------------------------------------------------- */
/* Add table "NhomHang"                                                   */
/* ---------------------------------------------------------------------- */

CREATE TABLE [NhomHang] (
    [id] INTEGER IDENTITY(0,1) NOT NULL,
    [ten] NVARCHAR(40),
    [ghi_chu] NVARCHAR(80),
    [ngay_cap_nhat_cuoi] DATETIME,
    CONSTRAINT [PK_NhomHang] PRIMARY KEY ([id])
)
GO

/* ---------------------------------------------------------------------- */
/* Add table "HangHoa"                                                    */
/* ---------------------------------------------------------------------- */

CREATE TABLE [HangHoa] (
    [id] INTEGER IDENTITY(0,1) NOT NULL,
    [ten] NVARCHAR(80),
    [ma_hang] INTEGER,
    [ma_nhom_hang] INTEGER,
    [ghi_chu] NVARCHAR(80),
    [gia_nhap] FLOAT,
    [ngay_cap_nhat_cuoi] DATETIME,
    CONSTRAINT [PK_HangHoa] PRIMARY KEY ([id])
)
GO

/* ---------------------------------------------------------------------- */
/* Add table "KhoHang"                                                    */
/* ---------------------------------------------------------------------- */

CREATE TABLE [KhoHang] (
    [id] INTEGER IDENTITY(0,1) NOT NULL,
    [ma_san_pham] VARCHAR(40),
    [soluong] VARCHAR(40),
    [ngay_cap_nhat_cuoi] DATETIME,
    CONSTRAINT [PK_KhoHang] PRIMARY KEY ([id])
)
GO

/* ---------------------------------------------------------------------- */
/* Add table "HoaDon"                                                     */
/* ---------------------------------------------------------------------- */

CREATE TABLE [HoaDon] (
    [id] INTEGER IDENTITY(0,1) NOT NULL,
    [tong_tien] FLOAT,
    [ma_khach_hang] INTEGER,
    [ngay_lap] DATETIME,
    CONSTRAINT [PK_HoaDon] PRIMARY KEY ([id])
)
GO

/* ---------------------------------------------------------------------- */
/* Add table "ChiTietHoaDon"                                              */
/* ---------------------------------------------------------------------- */

CREATE TABLE [ChiTietHoaDon] (
    [id] INTEGER IDENTITY(0,1) NOT NULL,
    [ma_hoa_don] INTEGER,
    [ma_san_pham] INTEGER,
    [so_luong] INTEGER,
    [gia_tien] FLOAT,
    CONSTRAINT [PK_ChiTietHoaDon] PRIMARY KEY ([id])
)
GO
